<header th:fragment="top-menu"
        xmlns:th="http://www.thymeleaf.org"
        xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
        class="navbar navbar-static-top mg0 g-navbar">
    <div class="container">
        <div class="navbar-header">
            <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#bs-navbar"
                    aria-controls="bs-navbar" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a th:href="@{/}" class="navbar-brand g-main-color">iWeather</a>
        </div>
        <nav class="collapse navbar-collapse">
            <ul class="nav navbar-nav g-menus g-main-color">
                <li>
                    <a th:href="@{/}" data-pjax>首页</a>
                </li>
                <li>
                    <a th:href="@{/api.html}" data-pjax>API 文档</a>
                </li>
                <li>
                    <a th:href="@{/channel/ZiXun}" data-pjax>资讯</a>
                </li>
                <!--<li>-->
                    <!--<a href="../components/">组件</a>-->
                <!--</li>-->
            </ul>
            <ul class="nav navbar-nav navbar-right g-main-color">
                <th:block th:if="${#authorization.expression('hasRole(''USER'')')}">
                    <li><a href="javascript:;;" th:href="@{/u}" th:text="${#authentication.getPrincipal().username}">用户名</a></li>
                    <li><a href="javascript:;;" th:href="@{/logout}">退出</a></li>
                </th:block>
                <th:block th:unless="${#authorization.expression('hasRole(''USER'')')}">
                    <li><a href="javascript:;;" class="login">登陆</a></li>
                    <li><a href="javascript:;;" class="register">注册</a></li>
                </th:block>
            </ul>
        </nav>
    </div>

</header>